package com.bed.lovewithpatientbed.config;

import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
import org.apache.shiro.web.util.WebUtils;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * @author xuxiaoding
 * @version 1.0.0
 * @ClassName LoginFormAuthenticationFilter.java
 * @Description 自定义 authc 过滤器
 */
public class LoginFormAuthenticationFilter extends FormAuthenticationFilter {

    @Override
    protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
        String loginType = request.getParameter("loginType");
        if ("ordinary".equals(loginType)) {
            saveRequest(request);
            WebUtils.issueRedirect(request, response, "/userlogin.html");
            return false;
        } else {
            return super.onAccessDenied(request, response);
        }
    }
}
